package com.sugar.psych.assessment.module.business.dal.mysql.userleavemessage;


import com.sugar.psych.assessment.framework.common.pojo.PageResult;
import com.sugar.psych.assessment.framework.mybatis.core.mapper.BaseMapperX;
import com.sugar.psych.assessment.framework.mybatis.core.query.MPJLambdaWrapperX;
import com.sugar.psych.assessment.module.business.dal.dataobject.user.UserDO;
import com.sugar.psych.assessment.module.business.dal.dataobject.userleavemessage.UserLeaveMessageDO;
import org.apache.ibatis.annotations.Mapper;
import com.sugar.psych.assessment.module.business.controller.admin.userleavemessage.vo.*;

/**
 * 用户留言 Mapper
 *
 * @author Ysugar
 */
@Mapper
public interface UserLeaveMessageMapper extends BaseMapperX<UserLeaveMessageDO> {

    default PageResult<UserLeaveMessageRespVO> selectPage(UserLeaveMessagePageReqVO reqVO) {
        return selectJoinPage(reqVO, UserLeaveMessageRespVO.class, new MPJLambdaWrapperX<UserLeaveMessageDO>()
                .selectAll(UserLeaveMessageDO.class)
                .selectAs(UserDO::getNickname, UserLeaveMessageRespVO::getNickname)
                .selectAs(UserDO::getMobile, UserLeaveMessageRespVO::getMobile)
                .leftJoin(UserDO.class, UserDO::getId, UserLeaveMessageDO::getUserId)
                .eqIfPresent(UserDO::getMobile, reqVO.getMobile())
                .likeIfPresent(UserLeaveMessageDO::getAnonymityName, reqVO.getAnonymityName())
                .eqIfPresent(UserLeaveMessageDO::getAnonymityAvatar, reqVO.getAnonymityAvatar())
                .eqIfPresent(UserLeaveMessageDO::getContent, reqVO.getContent())
                .betweenIfPresent(UserLeaveMessageDO::getValidTime, reqVO.getValidTime())
                .eqIfPresent(UserLeaveMessageDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(UserLeaveMessageDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserLeaveMessageDO::getId));
    }

}